<div class="content-wrapper">
    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right" id="dbshop-menu-top">
            <a href="<?php echo $this->url('template'); ?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?php echo $this->translate('返回电脑端模板'); ?></a>
            <?php echo $this->HelpUrl('template'); ?>
        </h1>
    </section>

    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href=""><?php echo $this->translate('电脑端模板安装'); ?></a></li>
                        <li><a href="<?php echo $this->url('template', ['action' => 'installMobileTemplate']); ?>"><?php echo $this->translate('手机端模板安装'); ?></a></li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="box-body">
                                <?php echo $this->partial('layout/messages'); ?>

                                <?php if (isset($this->result['code']) && $this->result['code'] == 200 && !empty($this->result['result']['templateList'])) foreach ($this->result['result']['templateList'] as $templateValue) { ?>
                                    <div class="col-lg-4" style="border: 1px solid #e3e3e3;">
                                        <img src="https://service.loongdom.cn/<?php echo $templateValue[0]['templateImage']; ?>" class="img-responsive pad">
                                        <div class="well row" style="margin-bottom: unset;border-radius: unset;border: 0;padding: 10px;">
                                            <div class="col-md-6">
                                                <strong style="font-size: 18px;"><?php echo $this->escapeHtml($templateValue[0]['templateName']); ?>&nbsp;<small>(<?php echo $templateValue[0]['templatePrice'] <= 0 ? $this->translate('免费') : '￥'.$templateValue[0]['templatePrice']; ?>)</small></strong>
                                            </div>
                                            <div class="col-md-6 text-right">
                                                <?php if (in_array($templateValue[0]['templateCode'], $this->templateCodeArray) || $templateValue[0]['templateCode'] == 'pc-default') { ?>
                                                    <button class="btn btn-success btn-sm"><i class="fa fa-desktop" aria-hidden="true"></i> <?php echo $this->translate('已安装'); ?></button>
                                                <?php } else { ?>
                                                    <button onclick="installTemplate('<?php echo $templateValue[0]['templateCode']; ?>');" class="btn btn-primary btn-sm"><i class="fa fa-crosshairs" aria-hidden="true"></i> <?php echo $this->translate('点击安装'); ?></button>
                                                <?php } ?>
                                            </div>
                                        </div>
                                    </div>
                                <?php } ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<?php if (isset($this->result['code']) && $this->result['code'] == 200 && !empty($this->result['result']['templateList'])) { ?>
<script>
    function installTemplate(templateCode) {
        layer.msg('<?php echo $this->translate('正在安装模板……，请不要关闭页面'); ?>', {
            icon: 16
            ,shade: 0.01
            ,time: 300000
        });
        $.post("<?php echo $this->url('template', ['action' => 'startInstallTemplate']); ?>", {templateCode:templateCode}, function (data) {
            if (data.state == 'false') {
                layer.alert(data.message, {title: '<?php echo $this->translate('错误提示'); ?>', area:['50%', '70%']});
                return false;
            }
            shopMessage(data.message);
            window.location.reload();
        }, 'json');
    }
</script>
<?php } ?>
